#include "includes.h"




int init_bsp()
{
	system("insmod /Skuo/dc_power.ko");
	return 0;
}


// cmd led power open 4 close 3
void lcd_power_on()
{
	int fd;
	fd = Open("/dev/dc_mute_sw", 0);
	ioctl(fd, 4, 0);
	close(fd);
}

void lcd_power_off()
{
	int fd;
	fd = Open("/dev/dc_mute_sw", 0);
	ioctl(fd, 3, 0);
	close(fd);
}


void power_output_on()
{
	int fd;
	fd = Open("/dev/dc_power", 0);
	ioctl(fd, 1);
	close(fd);
}

void power_output_off()
{
	int fd;
	fd = Open("/dev/dc_power", 0);
	ioctl(fd, 0);
	close(fd);
}

void restart_guest_device()
{
	err_msg("restart the guest device!!");
	power_output_off();
	sleep(1);
	power_output_on();
	sleep(10);
}

 static int get_power_adc()
{
	int fd;
	char buff;
	fd = Open("/dev/dc_adc8", 0);
	Read(fd, &buff, 1);
	close(fd);
	return (int)buff;
}

//mA
float get_power_current()
{
	int adc;
	float current;
	adc = get_power_adc();
	current = (3.3/1024)*adc*100;
	return current;
}
